<template>
  <el-switch
    :value="scope.row.status"
    :active-value="0"
    :inactive-value="1"
    active-text="正常"
    inactive-text="禁用"
    @change="changeStatus($event, scope.row.id, scope.$index)"
  />
</template>

<script>
// import { setStatus } from '@/svc/account'

export default {
  name: 'SetStatus',
  props: {
    fnEdit: { type: Function, default: null },
    scope: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  methods: {
    changeStatus(evt, id, index) {
      this.fnEdit(this, {
        id: id,
        status: evt
      }).then((res) => {
        // this.users[index].status = evt
        if (res) {
          this.$emit('statusChanged', id, index, evt)
          this.$success('修改成功')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
